// TuneWait.cpp : implementation file
//

#include "stdafx.h"
#include "voldia.h"
#include "TuneWait.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CTuneWait dialog


CTuneWait::CTuneWait(CWnd* pParent /*=NULL*/)
	: CDialog(CTuneWait::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTuneWait)
	m_progTxt = _T("");
	m_staticTxt = _T("");
	//}}AFX_DATA_INIT
}


void CTuneWait::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTuneWait)
	DDX_Control(pDX, IDC_PROG, m_prog);
	DDX_Text(pDX, IDC_PROG_TXT, m_progTxt);
	DDX_Text(pDX, IDC_STATIC_TXT, m_staticTxt);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTuneWait, CDialog)
	//{{AFX_MSG_MAP(CTuneWait)
	//}}AFX_MSG_MAP
	ON_MESSAGE( WM_TUNE_WAIT, OnTuneWait )
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTuneWait message handlers

BOOL CTuneWait::OnInitDialog() 
{
	CDialog::OnInitDialog();

	this->m_num = N_MAX_BLOCKS;

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

LRESULT CTuneWait::OnTuneWait(WPARAM wParam, LPARAM lParam){
	RETSTAT			retSt;

	if(wParam == 0){
		retSt = GetInfiBlockNum(&this->m_num);
		if(retSt != RT_NORMAL)
			this->m_num = N_MAX_BLOCKS;
		this->m_prog.SetRange(0, this->m_num);
		this->m_prog.SetPos(0);
		this->m_prog.SetStep(1);
		this->m_progTxt.Format(_T("Loaded 0 of %d"), this->m_num);
		this->m_staticTxt.Format(_T("Loading Infi90 blocks..."));
	}
	else{
		this->m_prog.StepIt();
		this->m_progTxt.Format(_T("Loaded %d of %d"), wParam, this->m_num);
	}

	this->UpdateData(false);
	return 0;
}
